/**
 * @param {number} n
 * @return {number}
*/
var fib = function(n) {
  if(n == 0 || n == 1) return n;
  let last1 = 0, last2 = 1, result = 0;
  for(let i = 2; i <= n; i++) {
    result = last1 + last2;
    if(result > 1000000007) result %= 1000000007;
    last1 = last2;
    last2 = result;
  }
  if(result > 1000000007) result %= 1000000007;
  return result;
};
let n = 2;
console.log(fib(n));
n = 5;
console.log(fib(n));

